<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\massage\model;

class CoachUpdate extends \app\BaseModel
{
    protected $name = "massage_service_coach_update";
    public function getTrueUserNameAttr($value, $data)
    {
        if(isset($value)) {
            if(!empty($value)) {
                return $value;
            }
            if(!empty($data["coach_name"])) {
                return $data["coach_name"];
            }
        }
    }
    public function getIdCardAttr($value, $data)
    {
        if(!empty($value)) {
            return explode(",", $value);
        }
    }
    public function getLicenseAttr($value, $data)
    {
        if(!empty($value)) {
            return explode(",", $value);
        }
    }
    public function getSelfImgAttr($value, $data)
    {
        if(!empty($value)) {
            return explode(",", $value);
        }
    }
    public function adminDataList($dis, $mapor, $page = 10)
    {
        $data = $this->alias("a")->join("shequshop_school_user_list b", "a.user_id = b.id")->where($dis)->where(function ($query) {
            $query->whereOr($mapor);
        })->field("a.*,b.nickName,b.avatarUrl")->group("a.id")->order("a.id desc")->paginate($page)->toArray();
        return $data;
    }
    public function dataAdd($data)
    {
        $data["create_time"] = time();
        $res = $this->insert($data);
        return $res;
    }
    public function dataUpdate($dis, $data)
    {
        $res = $this->where($dis)->update($data);
        return $res;
    }
    public function dataList($dis, $page = 10, $mapor)
    {
        $data = $this->where($dis)->where(function ($query) {
            $query->whereOr($mapor);
        })->order("distance asc,id desc")->paginate($page)->toArray();
        return $data;
    }
    public function dataInfo($dis, $file = "*")
    {
        $data = $this->where($dis)->field($file)->find();
        return !empty($data) ? $data->toArray() : [];
    }
}

?>